package daily.oct;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class lc3289 {
    /*
    比较简单的题目。复习了int[]和arraylist之间的转换api运用
     */
    public int[] getSneakyNumbers(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i],map.getOrDefault(nums[i],0)+1);
        }
        for (int i = 0; i < map.size(); i++) {
            if (map.get(i)!=1){
                list.add(i);
            }
        }
        int[] res=list.stream().mapToInt(Integer::intValue).toArray();
        return res;
    }

    public static void main(String[] args) {
        int[] nums1 = new int[]{0,1,1,0};
        int[] nums2 = new int[]{0,3,2,1,3,2};
        int[] nums3 = new int[]{7,1,5,4,3,4,6,0,9,5,8,2};
        lc3289 lc3289 = new lc3289();
        System.out.println(Arrays.toString(lc3289.getSneakyNumbers(nums1)));
        System.out.println(Arrays.toString(lc3289.getSneakyNumbers(nums2)));
        System.out.println(Arrays.toString(lc3289.getSneakyNumbers(nums3)));

    }
}
